package dao.impl;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import dao.Jingdong_product_categoryDao;
import entity.Jingdong_product_category;

public class Jingdong_product_categoryDaoImpl extends BaseDao implements Jingdong_product_categoryDao {

	@Override
	public List<Jingdong_product_category> categoryList() {
		String sql = "SELECT * FROM `jingdong_product_category`";
		List<Jingdong_product_category> productList= new ArrayList<Jingdong_product_category>();
		Jingdong_product_category jpc = null;
		Object[] params = {};
		ResultSet rs = this.executeQuery(sql, params);
		try {
			while (rs.next()) {
				jpc =  tableToClass(rs);
				productList.add(jpc);
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return productList;
	}

	@Override
	public Jingdong_product_category tableToClass(ResultSet rs) throws Exception {
			Jingdong_product_category jpc = new Jingdong_product_category();
			jpc.setId(rs.getInt("id"));
			jpc.setName(rs.getString("name"));
			jpc.setParentId(rs.getInt("parentId"));
			jpc.setType(rs.getInt("type"));
			jpc.setIconClass(rs.getString("iconClass"));
			jpc.setAttachment(rs.getString("attachment"));
		return jpc;
	}

}
